<template>
	<view class="page">
		<ChangePatient @sendinfo='getInfo'></ChangePatient>
		<!-- 就诊人切换 -->
		
		<!-- 导诊医生列表 -->
		<view class="doctorlists">
			<image style="width: 100%;text-align: center;margin-top: 100rpx;" src="https://cdn8.axureshop.com/demo/2208121/images/%E5%8C%BB%E7%94%9F%E5%88%97%E8%A1%A8/u875.png" mode="widthFix" v-if="guidancelists.length==0"></image>
			<view class="doctorlist" v-for="(item,index) in guidancelists" :key="index">
				<view class="doctor_info">
					<image style="width: 90rpx;" :src="item.avator" mode="widthFix"></image>
					<view class="textInfo">
						<view class="name_call">
							<view class="name">
								{{item.name}}
							</view>
							<view class="call">
								{{item.call}}
							</view>
						</view>
						<view class="depart_campus">
							<view class="depart">
								{{item.depart}}
							</view>
							<view class="campus">
								四川省保健院南苑
							</view>
						</view>
					</view>
				</view>
				<view class="registration_info">
					<view class="registration">
						登记号：2020{{new Date().getTime()}}Z
					</view>
					<view class="registration">
						预约时间：{{item.registortime}}（{{item.registortime.split(' ')[1]=='8:00-12:00'?'上午':'下午'}}）
					</view>
				</view>
				<view class="details" @click="details(item.patient,item.depart,item.name)">
					查看导诊详情 >
				</view>
			</view>
			
		</view>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import api from '../../src/utils/api.js'
	const guidancelists = reactive([])
	onLoad(()=>{
		api('/appselectpatientid',{
			memberid:0,
			userid:uni.getStorageSync('userid')
		}).then(res=>{
			api('/appselectoffnum',{
				patient_id:res.datas[0].patient_id
			}).then(res=>{
				guidancelists.push(...res.data)
			}).catch(err=>{
				console.log(err)
			})
		}).catch(err=>{
			console.log(err)
		})
	})
	// 切换就诊人
	const popup = ref(null)
	const open = () => {
		popup.value.open()
	}
	
	const close = () => {
		popup.value.close()
	}
	const getInfo = (data) => {
		guidancelists.splice(0)
		api('/appselectpatientid',{
			memberid:data.member_id==0?0:data.member_id,
			userid:uni.getStorageSync('userid')
		}).then(res=>{
			api('/appselectoffnum',{
				patient_id:res.datas[0].patient_id
			}).then(res=>{
				guidancelists.push(...res.data)
			}).catch(err=>{
				console.log(err)
			})
		}).catch(err=>{
			console.log(err)
		})
	}
	// 导诊详情
	const details = (patient,depart,doctor) => {
		uni.navigateTo({
			url:'/pages/Guidance_Details/Guidance_Details?patient='+patient+'&depart='+depart+'&doctor='+doctor
		})
	}
</script>

<style lang="scss" scoped>
	.page{
		background-color: rgba(242, 242, 242, 1);
		min-height: 100vh;
		padding: 32rpx 30rpx;
		box-sizing: border-box;
		// 就诊人切换
		.patient{
			width: 100%;
			height: 88rpx;
			background-color: #fff;
			border-radius: 16rpx;
			padding:  0 40rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.peopleInfo{
				display: flex;
				align-items: center;
				font-family: 'Microsoft YaHei UI', sans-serif;
				font-size: 28rpx;
				height: 44rpx;
				.name{
					font-size: 32rpx;
				}
				.patient_card{
					color: #aaa;
					margin-left: 44rpx;
				}
			}
			.operate{
				display: flex;
				align-items: center;
				font-family: 'Microsoft YaHei UI', sans-serif;
				font-size: 32rpx;
				color: #000;
				.qie{
					margin-left: 12rpx;
				}
			}
		}
		// 就诊人切换弹出层
		.popup{
			
			.popup-content {
				// display: flex;
				// flex-direction: column;
				// align-items: center;
				// justify-content: center;
				border-radius: 72rpx 72rpx 0 0;
				padding: 30rpx 45rpx 0;
				box-sizing: border-box;
				height: 804rpx;
				background-color: #fff;
				font-family: 'Microsoft YaHei UI Bold', 'Microsoft YaHei UI Regular', 'Microsoft YaHei UI', sans-serif;
				position: relative;
				.title{
					font-size: 32rpx;
					font-weight: 700;
					width: 100%;
					text-align: center;
				}
				.close{
					width: 32rpx;
					position: absolute;
					right: 45rpx;
					cursor: pointer;
					top: 38rpx;
				}
				
				.patientlists{
					margin-top: 60rpx;
					.patientlist{
						width: 660rpx;
						height: 92rpx;
						border-radius: 16rpx;
						padding: 0 30rpx;
						box-sizing: border-box;
						display: flex;
						align-items: center;
						background-color: rgba(230, 244, 255, 1);
						font-size: 28rpx;
						font-family: 'Microsoft YaHei UI', sans-serif;
						margin-bottom: 40rpx;
						.patient_card{
							margin-left: 20rpx;
							color: #aaa;
						}
					}
				}
				.addpatient{
					width: 660rpx;
					height: 80rpx;
					line-height: 80rpx;
					font-family: 'Microsoft YaHei UI', sans-serif;
					font-size: 28rpx;
					color: #fff;
					background-image: url('https://cdn8.axureshop.com/demo/2208121/images/%E9%97%A8%E8%AF%8A%E6%8C%82%E5%8F%B7/u579.svg');
					background-size: cover;
					position: absolute;
					bottom: 40rpx;
				}
			}
		}
		// 导诊医生列表
		.doctorlists{
			margin-top: 30rpx;
			.doctorlist{
				width: 100%;
				height: 402rpx;
				background-color: #fff;
				border-radius: 16rpx;
				padding: 36rpx 42rpx;
				box-sizing: border-box;
				margin-bottom: 30rpx;
				.doctor_info{
					display: flex;
					align-items: center;
					.textInfo{
						margin-left: 40rpx;
						.name_call{
							height: 50rpx;
							display: flex;
							align-items: baseline;
							font-family: 'Microsoft YaHei UI Regular', 'Microsoft YaHei UI', sans-serif;
							font-size: 26rpx;
							color: #1f1f1f;
							.name{
								font-family: 'Microsoft YaHei UI Bold', 'Microsoft YaHei UI', sans-serif;
								font-size: 36rpx;
								font-weight: 700;
								margin-right: 36rpx;
							}
						}
						.depart_campus{
							height: 40rpx;
							margin-top: 4rpx;
							display: flex;
							align-items: center;
							font-family: 'Microsoft YaHei UI Regular', 'Microsoft YaHei UI', sans-serif;
							font-size: 28rpx;
							color: #aaa;
							.depart{
								margin-right: 28rpx;
							}
						}
					}
				}
				.registration_info{
					margin-top: 40rpx;
					.registration{
						font-family: 'Microsoft YaHei UI', sans-serif;
						font-size: 28rpx;
						color: #333;
						margin-bottom: 16rpx;
					}
				}
				.details{
					width: 100%;
					height: 94rpx;
					line-height: 94rpx;
					text-align: center;
					font-family: 'Microsoft YaHei UI Regular', 'Microsoft YaHei UI', sans-serif;
					font-size: 28rpx;
					color: #1677FF;
					border-top: 2rpx solid #f2f2f2;
					margin-top: 44rpx;
					cursor: pointer;
				}
			}
		}
	}       
</style>
